<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增任务配置')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-post-add">

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">connectName：</label>
            <div class="col-sm-8">
                <select class="form-control" name="dbConfigId" id="dbConfigId" required>
                    <option value="">--请选择数据配置--</option>
                    <option th:each="dbList:${dbConfigList}" th:value="${dbList.id}"
                            th:text="${dbList.connectName}"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">源表：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="tableName" id="tableName"
                       placeholder="请填写库名和表名(例如:[db].[table])" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">源表主键：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="tablePrimary" id="tablePrimary"
                       required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">枚举字段探测：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="tableEnumFields" id="tableEnumFields"
                       placeholder="请填写字段名,用逗号分隔"/>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">空值探测：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="tableNullFields" id="tableNullFields"
                       placeholder="请填写字段名,用逗号分隔"/>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">长度探测：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="tableLengthFields" id="tableLengthFields"
                       placeholder="请填写字段名,用逗号分隔"/>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">过滤条件：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="filter" id="filter"
                       placeholder="请填写字段名,用逗号分隔"/>
            </div>
        </div>

    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script type="text/javascript">
    var prefix = ctx + "system/probeJobConfig";

    function submitHandler() {
        if ($.validate.form()) {
            //checkTableName(prefix + "/checkTableName", $('#form-post-add').serialize());
            $.operate.save(prefix + "/add", $('#form-post-add').serialize());

        }
    }


    function checkTableName(url, data, callback) {
        var config = {
            url: url,
            type: "post",
            dataType: "json",
            data: data,
            beforeSend: function () {
                $.modal.loading("正在处理中，请稍候...");
            },
            success: function (result) {
                if (typeof callback == "function") {
                    callback(result);
                }
                if (result.code == web_status.SUCCESS) {
                    //$.modal.alertSuccess(result.msg)
                    $.operate.save(prefix + "/add", $('#form-post-add').serialize());
                } else if (result.code == web_status.WARNING) {
                    $.modal.alertWarning(result.msg)
                } else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();
            }
        };
        $.ajax(config)
    }

</script>

</body>
</html>
